import { app, Menu } from 'electron'
let dockMenu = Menu.buildFromTemplate([
  {
    label: '播放',
    click: function () {
      console.log('播放')
    }
  },
  {
    label: '上一首',
    click: function () {
      console.log('上一首')
    }
  },
  {
    label: '下一首',
    click: function () {
      console.log('下一首')
    }
  },
  {
    type: 'separator'
  },
  {
    label: '重复',
    submenu: [{
      label: '关闭',
      click: function () {
        console.log('关闭')
      }
    }, {
      label: '全部',
      click: function () {
        console.log('全部')
      }
    }, {
      label: '单曲',
      click: function () {
        console.log('单曲')
      }
    }]
  },
  {
    label: '随机播放',
    click: function () {
      console.log('随机播放')
    }
  }
])

let appMenu = Menu.buildFromTemplate([
  {
    label: 'QQ音乐',
    submenu: [
      {
        label: '关于QQ音乐',
        role: 'about'
      },
      {
        label: '偏好设置',
        click: function () {
          console.log('偏好设置')
        }
      },
      { type: 'separator' },
      {
        label: '注销'
      },
      { type: 'separator' },
      {
        label: '隐藏QQ音乐',
        role: 'hide'
      },
      {
        label: '隐藏其他',
        role: 'hideothers'
      },
      {
        label: '显示全部',
        role: 'unhide'
      },
      { type: 'separator' },
      {
        label: '退出QQ音乐',
        click: function () {
          app.quit()
        }
      }
    ]
  },
  {
    label: '编辑',
    submenu: [
      {
        label: '剪切',
        accelerator: 'I',
        role: 'cut'
      },
      {
        label: '复制',
        role: 'copy'
      },
      {
        label: '粘贴',
        role: 'paste'
      },
      {
        label: '搜索',
        accelerator: 'CmdOrCtrl+F',
        click: function () {
          console.log('搜索')
        }
      }
    ]
  },
  {
    label: '播放控制',
    submenu: [{
      label: '播放',
      click: function () {
      }
    }, {
      label: '上一首',
      accelerator: 'CmdOrCtrl+Left',
      click: function () {
      }
    }, {
      label: '下一首',
      accelerator: 'CmdOrCtrl+Right',
      click: function () {
      }
    }]
  },
  {
    label: '窗口',
    submenu: [
      {
        label: '最小化',
        role: 'minimize'
      },
      {
        label: '关闭窗口',
        role: 'close'
      },
      {
        label: '缩放窗口',
        click: function () {
          console.log('缩放')
        }
      },
      { type: 'separator' },
      {
        label: 'QQ音乐 面板',
        accelerator: 'CmdOrCtrl+1',
        click: function () {
          console.log('QQ音乐 面板')
        }
      },
      {
        label: '切换到迷你窗口',
        accelerator: 'Shift+CmdOrCtrl+S',
        click: function () {
          console.log('切换到迷你窗口')
        }
      },
      { type: 'separator' },
      {
        label: '前置全部窗口',
        role: 'front'
      },
      { type: 'separator' },
      {
        label: '进入全屏幕',
        accelerator: 'Control+CmdOrCtrl+F',
        click: function (item, focusedWindow) {
          if (focusedWindow) {
            focusedWindow.setFullScreen(!focusedWindow.isFullScreen())
          }
        }
      }
    ]
  },
  {
    label: '帮助',
    role: 'help',
    submenu: [
      {
        label: '反馈'
      },
      {
        label: '发送日志'
      }
    ]
  }
])

export const setDockMenu = () => {
  dockMenu.closePopup()
  app.dock.setMenu(dockMenu)
  // app.dock.setIcon('/Users/yaavi/Desktop/1.png')
}

export const setAppMenu = () => Menu.setApplicationMenu(appMenu)
